﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MatterView : MonoBehaviour {
    public UnityEngine.UI.Text Name;
    public UnityEngine.UI.Text State;
    public UnityEngine.UI.Text Mass;
    public UnityEngine.UI.Text PresureOrVolume;

    Matter _m;
    MatterGrid _mg;
    public void SetMatter(Matter m,MatterGrid mg)
    {
        _m = m;
        _mg = mg;
        Name.text = m.matterType.Name;
        State.text = GetStateName(_m.currentMatterState);
        if (_m.currentMatterState == Matter.MatterState.Gas)
        {
            Mass.text = (_m.Mass * 1000).ToString("0") + "g";
            PresureOrVolume.text = _m.GetGasPressure(_mg.GetGasVolume(), _mg.Temperature).ToString("0") + "KPa";
        }
        else
        {
            Mass.text = (_m.Mass).ToString("0.0") + "Kg";
            PresureOrVolume.text = _m.GetVolume().ToString("0.0") + "m³";
        }
    }

    string GetStateName(Matter.MatterState ms)
    {
        switch(ms)
        {
            case Matter.MatterState.Gas:
                return "气";
            case Matter.MatterState.Solid:
                return "固";
            case Matter.MatterState.Liquid:
                return "液";
        }
        return "无";
    }


}
